<?php
/**
 * Created by PhpStorm.
 * User: Fight.节奏
 * Date: 2016/8/4
 * Time: 9:46
 */
//    获取热门的文章
$cateModel=new \Common\Model\Cate();
$arcModel=new \Common\Model\Arc();

$datahot=$arcModel->join('category','category_cid','=','cid')->where("is_recycle=0")
    ->orderBy('click','DESC')->limit(5)->get();
//获得标签云
$arcTagModel=new \Common\Model\Arctag();
$tagModel=new \Common\Model\Tag();
        $tagData=$tagModel->get();
        foreach($tagData as $k=>$v){
            $tagData[$k]['total']=$arcTagModel->join('article','article_aid','=','aid')->where("tag_tid={$v['tid']}")->where("is_recycle=0")->count();
        }
        View::with('tagData',$tagData);


$arcModel=new \Common\Model\Arc();
$cateModel=new \Common\Model\Cate();
//        获得所有的分类数据
$cateData=$cateModel->get();
//递归调用分类列表
foreach($cateData as $k=>$v){
    $cids = $cateModel->getSon($cateModel->get(),$v['cid']); //()里面是形参
    //把当前(自己)压入数组
    $cids[] = $v['cid'];
    //查询文章表统计总数
    $total = $arcModel
        ->where("category_cid IN (" . implode(',', $cids) . ")")
        ->where("is_recycle=0")
        ->count();
    //追加字段total
    $cateData[$k]['total'] = $total;
}

?>
<div class="rnav">
    <?php foreach ($cateData as $v){?>
    <li class="rnav<?php echo mt_rand(1,4)?> "><a href="c_<?php echo $v['cid']?>.html"><?php echo $v['cname']?>(<?php echo $v['total']?>)</a></li>
    <?php }?>
</div>
<div class="ph_news">
    <h2>
        <p class="tj_t1">热门文章</p>
    </h2>
    <ul>
        <?php foreach ($datahot as $u){?>
        <li><a href="a_<?php echo $u['aid']?>.html" ><?php echo $u['title']?></a><span style="color: white;float: right; margin-right: 30px;">(阅读：<?php echo $u['click']?>次)</span></li>
        <?php }?>
    </ul>
    <h2>
        <p class="tj_t2">标签云</p>
    </h2>
    <ul>
        <?php foreach ($tagData as $u){?>
        <li><a href="t_<?php echo $u['tid']?>.html"><?php echo $u['tname']?>(<?php echo $u['total']?>)</a></li>
        <?php }?>
    </ul>
    <h2>
        <p>最新评论</p>
    </h2>
    <ul class="pl_n">

<!--            <img src="images/s8.jpg">-->
                        <dt></dt>
<!--            <dt> </dt>-->
<!--            <dd>DanceSmile-->
<!--                <time>49分钟前</time>-->
<!--            </dd>-->
        <dd><div class="ds-recent-comments" data-num-items="5" data-show-avatars="1" data-show-time="1" data-show-title="1" data-show-admin="1" data-excerpt-length="70"></div></dd>

    </ul>

    <!-- 多说最新评论 start -->
<!--    <div class="ds-recent-comments" data-num-items="5" data-show-avatars="1" data-show-time="1" data-show-title="1" data-show-admin="1" data-excerpt-length="70"></div>-->
    <!-- 多说最新评论 end -->
    <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
    <script type="text/javascript">
        var duoshuoQuery = {short_name:"yjlvip"};
        (function() {
            var ds = document.createElement('script');
            ds.type = 'text/javascript';ds.async = true;
            ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
            ds.charset = 'UTF-8';
            (document.getElementsByTagName('head')[0]
            || document.getElementsByTagName('body')[0]).appendChild(ds);
        })();
    </script>
    <!-- 多说公共JS代码 end -->
